home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1243 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.1 KB  |  48 lines

  1. Newsgroups: comp.lang.c++
  2. Path: watserv3.uwaterloo.ca!athena
  3. From: sdbay@watnow.uwaterloo.ca (Stephen Bay)
  4. Subject: Question: references to variables within classes
  5. Message-ID: <DKy0MC.3nA@watserv3.uwaterloo.ca>
  6. Sender: news@watserv3.uwaterloo.ca
  7. Nntp-Posting-Host: cnts2p06.uwaterloo.ca
  8. Organization: University of Waterloo
  9. X-Newsreader: News Xpress Version 1.0 Beta #4
  10. Date: Wed, 10 Jan 1996 02:08:36 GMT
  11.  
  12. Hi,
  13.  
  14. Is it possible in C++ to use variables within a class as parameters for a 
  15. constructor of an object contained within that class? I've tried compiling the 
  16. following code and my compiler chokes on the list iter declaration within the 
  17. class dodo - it doesn't recognize CityList and gives a syntax error. All the 
  18. other statements compile fine though.
  19.  
  20. -stephen
  21.  
  22.  
  23. #include "slist.hpp"
  24.  
  25. NISList<int *>            CityList;
  26. NISListIter<int *>        CityListIter(CityList);
  27.  
  28. struct bird
  29. {
  30.     NISList<int *>            CityList;
  31.     NISListIter<int *>        CityListIter();
  32. };
  33.  
  34. class    dodo
  35. {
  36.     public:
  37.         NISList<int *>            CityList;
  38. chokes here->    NISListIter<int *>        CityListIter(CityList);
  39. };
  40.  
  41. main()
  42. {
  43.     NISList<int *>            CityList;
  44.     NISListIter<int *>        CityListIter(CityList);
  45. };
  46.  
  47.  
  48.